package org.ry.camera.adapter;
import java.util.List;

import org.ry.camera.R;
import org.ry.camera.bean.PretendBean;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
/**
 * 
 * @author renyang
 *
 */
public class PretendAdapter extends BaseAdapter{
	
	private List<PretendBean> mPretendList;
	
	private final LayoutInflater mInflater;
	
	public PretendAdapter(List<PretendBean> mPretendList,Context mContext){
		this.mPretendList = mPretendList;
		mInflater = LayoutInflater.from(mContext);
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mPretendList.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return mPretendList.get(arg0);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		
		 ViewHolder holder;
		 
		 if(convertView == null){
			 
			 convertView = mInflater.inflate(R.layout.item_pretend, null);
			 
			 holder = new ViewHolder();
			 
			 holder.mTextView = (TextView)convertView.findViewById(R.id.pretend_adapter_name);
			 
			 convertView.setTag(holder);
		 }else{
			 holder = (ViewHolder) convertView.getTag();
		 }
		
		 PretendBean mPretendBean =  mPretendList.get(position);
		 
		 holder.mTextView.setText(mPretendBean.getmName());
		 
		return convertView;
	}
	
	static class ViewHolder{
		
		ImageView mImageView;
		
		TextView mTextView;
		
	}
}
